﻿
///将点数转换成度数
function getArray(data) {

    var len = data.length;
    var array = new Array(len);

    for (var i = 0; i < len; i++) {
        var xValue = 360 / len * (i + 1);
        array[i] = [xValue, data[i]];

    }
    return array;

}

///描一条曲线
function drawSingleSpline(ID) {
    $.ajax({
        url: 'ajax_analysis.ashx',
        type: 'get',
        dataType: 'xml', //这里可以不写，但千万别写text或者html!!! 
        data: { id: ID, field: "HYGGL" },
        timeout: 2000,
        cache: false,
        error: function (xml) {
            alert('数据有错误' + xml);
        },
        success: function (xml) {
            var data1 = [];
            $(xml).find("tables").children().each(function () {
                var l = $(this).children("l").text();
                data1.push(Number(l));
            });
           
            var chart = $('#container').highcharts();
            chart.addSeries({
                data: getArray(data1),
                color: '#0000AA'
            });

      //   p.attr("title", chart.series.length - 1);
        }
    });
}
var fun;
$(document).ready(fun = function () {
 drawSingleSpline(13752);

 //返回主页面
 $('#backMain').click(function () {
     parent.openSonPage("analysisMain.aspx");
 });
 ///描图控件属性设置
 $('#container').highcharts({
    

     chart: {
         zoomType: 'x',
         type: 'area',
         marginRight: 5,
         events: {
             load: function () {

             }
         }
     },
     xAxis: {
         max: 360,
         tickInterval: 20
     },

     title: {
         text: '',
         x: -20 //center
     },
     subtitle: {
         text:'',
         x: -20
     },

     yAxis: {

         max: 50,
         min: -10,
         title: {
             text: ''
         },
         plotLines: [{
             value: 0,
             width: 1,
             color: '#808080'
         }]
     },
    
     tooltip: {
         valueSuffix: ''
     },
     legend: {
         layout: 'vertical',
         align: 'right',
         verticalAlign: 'middle',
         borderWidth: 0
     },
     plotOptions: {

         
         series: {
             animation: {
                 duration: 10
             },
             fillColor: {
                 linearGradient: [0, 0, 0, 290],
                 stops: [
                        [0, 'rgba(220, 9, 36,0.7)'],
                        [0.72, 'rgba(220, 9, 36,0.7)'],
                        [0.72, 'rgba(252,216,29,0.7)'],
                        [0.8, 'rgba(252, 216, 29,0.7)'],
                        [0.8, 'rgba(3,177,72,0.7)'],
                        [0.933, 'rgba(3,177,72,0.7)'],
                        [0.933, 'rgba(0,21,213,0.7)'],
                        [1, 'rgba(0,21,213,0.7)'],
                    ]
             },
             fillOpacity: 0.8
         },

         area: {
             marker: {
                 enabled: false,
                 symbol: 'circle',
                 radius: 2,
                 states: {
                     hover: {
                         enabled: true
                     }
                 }
             }
         }

     },
     series: []
 });



});
